from django.shortcuts import render
from django.http import HttpResponse
from django.shortcuts import reverse,redirect

#路由重定向
def myapp(request):
    print(reverse('myapp:turnTo'))
    return redirect(reverse('myapp:sum',args=[2019,13]))

def sum(request,num1,num2):
    return HttpResponse(str(num1)+'/'+str(num2))

""" def myapp(request):
    args = [2002, 6]
    # 使用reverse生成路由地址
    print(reverse('myapp:sum', args=args))
    return HttpResponse(reverse('myapp:sum', args=args))

def sum(request,num1,num2):
    result = reverse('myapp:sum')
    return HttpResponse(str(num1)+'/'+str(num2))
 """
#def myapp(request):
#    return render(request, 'myapp.html')

#不带参数的路由对应的视图函数
def zero(request):
    return HttpResponse('Hello,Django!')

#带参数的路由对应的视图函数
#def sum(request,num1,num2):
#    return HttpResponse(f'The sum is {num1+num2}')

#正则表达式参数路由对应的视图函数
def post_num(request,id):
    return HttpResponse(str(id))

